<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>OurBarangay.com >> Landmarks</title>
        <link rel="Stylesheet" href="<?php echo base_url();?>assets/css/general.css" />
        <link rel="Stylesheet" href="<?php echo base_url();?>assets/css/common.css" />
        <link rel="Stylesheet" href="<?php echo base_url();?>assets/css/sk.css">
        <script type="text/javascript" src="<?php echo base_url();?>assets/js/asynch.js"></script>
        <style type="text/css">
            .body_right {
                background-color: #fff;
            }
            .prim_inf {
                padding: 0px 8px;
            }
            td.info {
                padding: 7px;
            }
            td.commit {
                text-align: right;
                font-size: 11px;
            }
            td.commit a {
                color: #333;
            }
            td.commit a:hover {
                text-decoration: none;
            }
            textarea {
                width: 649px;
                height: 200px;
            }
            input[type="text"], input[type="password"], .unedit_info {
                width: 258px;
            }
            textarea {
                
            }
        </style>
    </head>
    <body>
        <div class="container">
            <?php $this->load->view('main_admin_panel'); ?>
            <?php $this->load->view('main_head'); ?>
            <div class="body">
                <?php $this->load->view('main_body_left'); ?>
                <div class="body_right">
                    <div class="prim_inf">
                        <div class="main_article">
                            <span class="main_article_title">
                                 Edit Official Information
                              <!--   <a href="#" id="dialog_link">Edit</a>-->
                            </span>
                            <hr/>
                            <form action="<?php echo base_url(); ?>index.php/sk/edit" method="POST">
                                <table style="padding-left:1em;">
                                    <tr>
                                        <td class="info">
                                            <span class="left_box_art_details">SK Official under</span>
                                            <br />
                                            <span class="unedit_info"><?php echo $this->session->userdata('barangay') . ', ' . $this->session->userdata('municipality') . ', ' . $this->session->userdata('province');?></span>
                                        </td>

                                    </tr>
                                     <?php 
                                       foreach($data_ofcl  as $row) {
                                    ?> 
                                     <tr>
                                        <td class="info">
                                             <?php if($row->official_position_id_fk == 5){ ?>
                                                  <img class='cap_image' src='<?php echo base_url();?>uploads/officials/sk/chairman/<?php echo $row->official_photo_path ?>'/>
                                            <?php } ?>
                                            <?php if($row->official_position_id_fk == 6){ ?>
                                                  <img class='cap_image' src='<?php echo base_url();?>uploads/officials/sk/councilors/<?php echo $row->official_photo_path ?>'/>
                                            <?php } ?>
                                                  <?php if($row->official_position_id_fk == 7){ ?>
                                                  <img class='cap_image' src='<?php echo base_url();?>uploads/officials/sk/secretary/<?php echo $row->official_photo_path ?>'/>
                                            <?php } ?>
                                            <?php if($row->official_position_id_fk == 8){ ?>
                                                  <img class='cap_image' src='<?php echo base_url();?>uploads/officials/sk/treasurer/<?php echo $row->official_photo_path ?>'/>
                                            <?php } ?>
                                            
                                        </td>

                                    </tr>
                                    <tr>
                                        <td class="info">
                                            <span class="left_box_art_details">Officials Firstname</span>
                                            <br />
                                            <input type="text" id="f_name" name="f_name" value="<?php echo $row->official_firstname?>" />
                                        </td>
                                    </tr>  
                                    <tr>
                                        <td class="info">
                                            <span class="left_box_art_details">Officials Middlename</span>
                                            <br />
                                            <input type="text" id="m_name" name="m_name" value="<?php echo $row->official_middlename?>" />
                                        </td>
                                    </tr>  
                                    <tr>
                                        <td class="info">
                                            <span class="left_box_art_details">Officials Lastname</span>
                                            <br />
                                            <input type="text" id="l_name" name="l_name" value="<?php echo $row->official_lastname?>" />
                                            <input type="hidden"  name="id" value="<?php echo $row->official_id_pk?>" />
                                        </td>
                                    </tr>  
                                    <tr>
                                        <td colspan="2" class="commit">
                                            <input type="submit" value="edit"/>
                                        </td>
                                    </tr>
                                    <?php }?>
                                </table>
                            </form>
                        </div>
                    </div>
                </div>
            </div>
             
            <div class="footer">
                <div class="footer_brgy_info">
                    Brgy Info
                </div>
                <div class="footer_sysnet">
                    Sysnet
                </div>
            </div>
        </div>
        <script type="text/javascript">
            $(document).ready(function() {
                <?php if($this->session->userdata('barangay_id') != '' || $this->session->userdata('barangay_id') != null) { ?>
                /*
                 * Asynchronous requests that are common
                 **/
                weeklyBulletin();
                latestBarangayUpdate();
                /*
                 * Asynchronous requests that are native to the page
                 **/
                //brgyDesc('edit');
                
                // In the future, the way should be like below
               //<php if($this->input->get('landmarks_id')) { ?>Update Landmark<php } else { ?>Add New Landmark<php } ?>
                
                var crudLandmarks = $("#landmark_submit_ae").click(function(){
                    $.ajax({
                        type:"post",
                        url:"<?php echo base_url();?>index.php/landmarks/crudLandmarks/ajax",
                        data:"l_submit=y&l_id=<?php echo $this->input->get('landmarks_id'); ?>&l_name="+$("#l_name").val()+"&l_addr="+$("#l_addr").val()+"&l_det="+$("#l_det").val(),
                        success:function(data) {
                            window.location.href="<?php echo base_url();?>index.php/landmarks";
                        },
                        error:function(data, textStatus) {
                            document.write(textStatus);
                        }
                    });
                });
                
                <?php } ?>
            });
        </script>
     
    </body>
</html>
